package com.ruoyi.api.controller;

import com.ruoyi.api.domain.BizPhoneLocation;
import com.ruoyi.api.dto.BizPhoneLocationDTO;
import com.ruoyi.api.dto.BizPhoneResourceDTO;
import com.ruoyi.api.service.IBizPhoneLocationService;
import com.ruoyi.api.service.IBizPhoneRecordService;
import com.ruoyi.api.service.IBizPhoneService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import org.apache.poi.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @author 魏建波
 * Date:  2022/1/21
 * Time:  18:31
 * @description 不需要验证的控制器
 */
@RestController
@RequestMapping("/api")
public class NoAuthController  extends BaseController {
    @Autowired
    private IBizPhoneLocationService bizPhoneLocationService;
    @Autowired
    private IBizPhoneRecordService bizPhoneRecordService;
    /**
     * 新增电话位置
     */
    @RequestMapping("/location")
    public AjaxResult add(BizPhoneLocation bizPhoneLocation)
    {
        if(StringUtils.isEmpty(bizPhoneLocation.getLatitude()) || StringUtils.isEmpty(bizPhoneLocation.getLongitude())
                || StringUtils.isEmpty(bizPhoneLocation.getPhoneSn())){
            return toAjax(0);
        }
        return toAjax(bizPhoneLocationService.insertBizPhoneLocation(bizPhoneLocation));
    }
    /**
     * 接收图片或者音频
     */
    @RequestMapping("/recordResource")
    public AjaxResult addRecordResource(BizPhoneResourceDTO bizPhoneLocationDTO)
    {
        int row = bizPhoneRecordService.addRecordResource(bizPhoneLocationDTO);
        return toAjax(row);
    }


}